package com.example.demo.controller;

import com.example.demo.entity.Admin;
import com.example.demo.entity.Laboratory;
import com.example.demo.service.AdminService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/admin")
public class AdminController {
   @Autowired
    private AdminService adminService;
    @PostMapping("/login")
    public Admin login(@RequestBody Admin admin){
        if(admin.getName()==null||admin.getPassword()==null){
            return null;
        }
        return adminService.login(admin.getName(),admin.getPassword());
    }
    @PostMapping("/list")
    public List<Admin> list(@RequestBody Admin admin){
        return adminService.selectList(admin);
    }


    @PostMapping("/delete")
    public int delete(@RequestBody  Admin admin){
        if(admin.getId()==null){
            return 0;
        }
        return adminService.delete(admin.getId());
    }
}
